﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace InstaGM
{
    public partial class host_settings : Form
    {

        gui frm = new gui();

        public host_settings()
        {
            InitializeComponent();
            ToolTip tooltip = new ToolTip();
            tooltip.ToolTipIcon = ToolTipIcon.Info;
            tooltip.ToolTipTitle = "Information";
            tooltip.IsBalloon = true;
            tooltip.ShowAlways = true;
            tooltip.SetToolTip(connect_at_start_q, "Checking this option will tell InstaGM that you want to connect to Telnet immediately after it's launched");
            tooltip.SetToolTip(host_q, "If you're using InstaGM locally you can use localhost as your host, if your doing so remotely it is recommended to use the target machines IP.");
            tooltip.SetToolTip(db_port_q, "If you're connecting to a Remote Database with a custom port you should fill this in, if not leave it blank.");
        }


        private void instagm_settings_load(object sender, EventArgs e)
        {
            host.Text = Properties.Settings.Default.host;
            port.Text = Properties.Settings.Default.port.ToString();
            db_port.Text = Properties.Settings.Default.db_port.ToString();
            pass.Text = Properties.Settings.Default.pass;
            auto_conn.Checked = Properties.Settings.Default.auto_conn;
        }


        private void button1_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.host = host.Text;
            Properties.Settings.Default.port = Convert.ToInt32(port.Text);
            Properties.Settings.Default.pass = pass.Text;
            Properties.Settings.Default.db_port = Convert.ToInt32(db_port.Text);

            if (auto_conn.Checked == true)
            {
                Properties.Settings.Default.auto_conn = true;
            }
            else
            {
                Properties.Settings.Default.auto_conn = false;
            }

            Properties.Settings.Default.Save();
            Application.Restart();

        }
    }
}
